<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>
{template header}
{template top}
<div id="uc">
{template uc/left}
	<div id="uc_main">
		<div class="uc_tab">
			<ul>
			<li><span><a{if !$action} class="on"{/if} href="{url home.php?m=point}">{$lang['my_point']}</a></span></li>
			<li><span><a{if $action == 'recharge'} class="on"{/if} href="{url home.php?m=point&a=recharge}">{$lang['point_recharge']}</a></span></li>
			<li><span><a{if $action == 'rule'} class="on"{/if} href="{url home.php?m=point&a=rule}">{$lang['point_rule']}</a></span></li>
			<!-- li><span><a{if $action == 'service'} class="on"{/if} href="{url home.php?m=point&a=service}">{$lang['point_service']}</a></span></li-->
			<li><span><a{if $action == 'log'} class="on"{/if} href="{url home.php?m=point&a=log}">{$lang['point_log']}</a></span></li>
			</ul>
		</div>
		<div id="uc_contain">
		{if !$action}
			<dl class="pointorder"><dt>{$lang['your_points']}: {echo intval($stat[$_G['settings']['point']['pointuse']]);}</dt>
				<dd>{$lang['point_use_type']}</dd>
				{if count($orders)>0}
				<dd>
				<table class="uc_table">
					<tr><th>{$lang['order_sn']}</th><th>{$lang['order_point_num']}</th><th>{$lang['order_gross']}</th><th>{$lang['order_time']}</th><th>{$lang['order_status']}</th></tr>
					{loop $orders $k $v}
					<tr><td>{$v['txnid']}</td><td>{$v['amount']}</td><td>{$v['gross']}</td><td>{echo gdate('Y-m-d H:i:s',$v['created'])}</td><td>
					{if $v['status']<2}<a href="{echo url('home.php?m=payment&f=pay&id='.$v['txnid'].'&type='.$v['payment_type'])}" onclick="return payment_form(this.href);">{$lang['goto_pay']}</a>{elseif $v['status'] == 2}{elseif $v['status'] >=3}{$status[$v['6']]}{/if}</td></tr>
					{/loop}
				</table>
				</dd>
				{/if}
			</dl>
			<script type="text/javascript">
			function payment_form(u){
				var edit = art.dialog({
				    title: '<?php echo $lang['goto_pay']?>',
				    fixed: true, 
				    width:350,
				    height:200,
				    padding:'10px 0 0',
				    cssname:'uc_gotopay',
				    content: '<iframe src="'+u+'" frameborder="0" style="width:350px;height:200px;overflow:hidden;" />'
					});
				return false;
			}
			</script>
		{/if}
		<?php if($action == 'recharge'):?>
			<form class="buypoint" name="friend_add" method="post" action="<?=url('home.php?m=point&a=recharge')?>" onsubmit="return point_recharge();">
				<dl><dt>1.<?php echo $lang['choose_recharge_num']?>:<span id="renum_warn" style="display:none;color:red;"><?php echo $lang['input_recharge_num'];?></span></dt>
					<dd>
					<label><input type="radio" name="recharge_num" value="30" onclick="ck_num();"/>30<?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong><?php echo $ratio * 30;?></strong><?php echo $lang['yuan'];?>)</label>
					<label><input type="radio" name="recharge_num" checked="checked" value="50" onclick="ck_num();"/>50<?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong><?php echo $ratio * 50;?></strong><?php echo $lang['yuan'];?>)</label>
					<label><input type="radio" name="recharge_num" value="100" onclick="ck_num();"/>100<?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong><?php echo $ratio * 100;?></strong><?php echo $lang['yuan'];?>)</label><br/>
					<label><input type="radio" name="recharge_num" value="150" onclick="ck_num();"/>150<?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong><?php echo $ratio * 150;?></strong><?php echo $lang['yuan'];?>)</label>
					<label><input type="radio" name="recharge_num" value="300" onclick="ck_num();"/>300<?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong><?php echo $ratio * 300;?></strong><?php echo $lang['yuan'];?>)</label>
					<label><input type="radio" name="recharge_num" value="0" onclick="$('#recharge_numo').focus();$('#cknum').val(1);"/><?php echo $lang['other'];?> <input type="text" onkeyup="checkpoint(this);" id="recharge_numo" name="recharge_numo" style="width:50px;"/><?php echo $setting[$_G['settings']['point']['pointuse']]['title'];?>(<strong id="point_value">0</strong><?php echo $lang['yuan'];?>)</label>
					<div style="clear:both"><input type="hidden" name="cknum" id="cknum" value="0"/><input type="hidden" name="ckpay" id="ckpay" value="0"/></div>
					</dd><script type="text/javascript">function checkpoint(obj){
						var s =  obj.value;
						if(!s){
							$('#point_value').html(0);
							return ;		
						}
						if(isNaN(s)||s<0){
							s = parseInt(s);
							if(isNaN(s)){
								obj.value=0;
								$('#point_value').html(0);
							}else{
								obj.value=s;
								$('#point_value').html(s*<?php echo $ratio;?>);
							}
							
						}else{
							s = obj.value = parseInt(s);
							$('#point_value').html(s*<?php echo $ratio;?>);
						}
					}
					$(function(){
							$('#point_value').html($('#recharge_numo').val()*<?php echo $ratio;?>);
						});
					function point_recharge(){
						if($('#cknum').val()>0 && $('#recharge_numo').val() < 1){
							$('#renum_warn').show();
							return false;
						} else {
							$('#renum_warn').hide();
						}
						if($('#ckpay').val()<1){
							$('#repay_warn').show();
							return false;
						}else{
							$('#repay_warn').hide();
						}
						return true;}
					function ck_num(){
						$('#cknum').val(0);
						$('#renum_warn').hide();
					}
					
					</script>
				</dl>
				<dl><dt>2.<?php echo $lang['choose_payment_type']?>:<span id="repay_warn" style="display:none;color:red;"><?php echo $lang['choose_payment_type'];?></span></dt>
				{loop $payments $k $v}
				<dd><input type="radio" name="payment" onclick="$('#ckpay').val(1);" value="{$k}"/><?php echo $lang[$k];?></dd>
				{/loop}
					
				
				</dl>
				<dl><dt></dt><dd><input type="submit" style="width:150px;" value="<?php echo $lang['pay_now'];?>" class="btnstyle"></dd></dl>
			</form>
		
		<?php endif;?>
		<?php if($action == 'del'):?>
		<?php endif;?>
		<?php if($action == 'log'):?>
			<table class="uc_table">
					<tr><th><?php echo $lang['time'];?></th><th><?php echo $lang['operation'];?></th><th><?php echo $lang['point'];?></th><th><?php echo $lang['detail'];?></th></tr>
					<?php foreach($logs as $k => $v):?>
					<tr><td><?php echo gdate('Y-m-d H:i:s',$v['dateline']);?></td><td><?php echo $lang[$v['operation']];?></td><td><?php echo $v[$_G['settings']['point']['pointuse']];?></td><td><?php echo $lang['relateid'];?></td></tr>
					<?php endforeach;?>
				</table>
		<?php endif;?>
		<?php if($action == 'rule'):?>
			
				<table class="uc_table">
					<tr><th><?php echo $lang['receive_condition'];?></th><th><?php echo $lang['cycletype'];?></th><th><?php echo $lang['cycletime'];?></th><th><?php echo $lang['point_value'];?></th></tr>
				<?php foreach($rules as $k=> $v):?>
					<tr><td><?php echo $v['detail'];?></td><td><?php echo $lang['cycle_type_'.$v['cycletype']];?></td><td>{if $v['cycletime']<1}{echo $lang['cycletime_'.$v['cycletime']]}{else}{$v['cycletime']}{/if}</td><td><?php echo $v[$_G['settings']['point']['pointuse']];?></td></tr>
				<?php endforeach;;?>
				</table>
			
		<?php endif;?>
		</div>
	</div>
	<div id="uc_right"></div>

</div>
<script type="text/javascript">
function chanfefriend(u,t){
	var edit = art.dialog({
	    title: '<?php echo $lang['change_friend']?>',
	    fixed: true, //C=G.DW
	    width:550,
	    height:400,
	    padding:'0 0 0 15px',
	    cssname:'uc_editfrind',
	    content: '<iframe src="'+u+'" frameborder="0" style="width:550px;height:400px;" />'
		});
//	$.get(u,'',function(data){
//		edit.content(data);
//		});
	
	return false;
}
function deletefrind(u,id){
	if(confirm('<?php echo $lang["confirm_delete"];?>')){
		$.getJSON(u+'&tm='+Math.random(),'',function(data){
			if(data.status==true){
				$('#'+id).hide();
			}else{
				art.dialog({fixed: true,time: 2,content: data.msg});
			}
			});
	}
	return false;
	
}
</script>
{template footer}